<?php
/**
*
*/

// no direct access
defined('_JEXEC') or die('Restricted access');



class modTestHelper
{
	function getOnlineCount()
	{
		//get database
		$db =& JFactory::getDBO();
		$sessions = null;
		$result  = array();
		$user_array = 0;
		$guest_array = 0;
		$query = 'SELECT guest, usertype, client_id' .
					' FROM #__session' .
					' WHERE client_id = 0';
		$db->setQuery($query);
		$sessions = $db->loadObjectList();
		if($db->getErrorNum())
		{
			JError::raiseWarning( 500, $db->stderr() );
		}
		if (count($sessions)) {
			foreach($sessions as $session) {
				if($session->guest == 1 && !$session->usertype) {
					$guest_array ++;
				}
				if($session->guest == 0) {
				$user_array ++;
				}
			}
			
		}
		$result['user'] = $user_array;
		$result['guest'] = $guest_array;
		return $result;
	}
}
